package evo;

import ids.PlacementMove;
import ids.PlacementState;
import ids.Sensor;

import java.io.File;
import java.io.FileNotFoundException;
import java.lang.reflect.Field;
import java.util.Scanner;
import java.util.Vector;

import util.Nodes;

public class TechInit {

	private PlacementState state;

	private PlacementMove move;

	private int numberOfRuns;

	private long seed;

	private float coolingRate;

	private int maxTemperatureCycles;

	private int movesAtEachTemperature;

	private int maxIdleTemperatureCycles;
	
	private Nodes nodes;
	
	private Vector<Sensor> sensors;

	public void processParamsFile(File paramsFile) throws FileNotFoundException {
		Scanner scanner = new Scanner(paramsFile);
		try {
			while (scanner.hasNextLine()) {
				String param = scanner.nextLine();
				if (param.startsWith("Seed")) {
					this.seed = new Long(param
							.substring(param.indexOf('=') + 1).trim());
				}
				if (param.startsWith("Cooling.Rate")) {
					this.coolingRate = new Float(param.substring(
							param.indexOf('=') + 1).trim());
				}
				if (param.startsWith("Max.Temperature.Cycles")) {
					this.maxTemperatureCycles = new Integer(param.substring(
							param.indexOf('=') + 1).trim());
				}
				if (param.startsWith("Moves.At.Each.Temperature")) {
					this.movesAtEachTemperature = new Integer(param.substring(
							param.indexOf('=') + 1).trim());
				}
				if (param.startsWith("Max.Idle.Temperature.Cycles")) {
					this.maxIdleTemperatureCycles = new Integer(param
							.substring(param.indexOf('=') + 1).trim());
				}
			}
		} finally {
			scanner.close();
		}
	}

	public PlacementState getState() {
		return state;
	}

	public void setState(PlacementState state) {
		this.state = state;
	}

	public PlacementMove getMove() {
		return move;
	}

	public void setMove(PlacementMove move) {
		this.move = move;
	}

	public long getSeed() {
		return this.seed;
	}

	public void setSeed(long seed) {
		this.seed = seed;
	}
	
	public Nodes getNodes() {
		return nodes;
	}

	public void setNodes(Nodes nodes) {
		this.nodes = nodes;
	}

	public Field[] getAllFields() {
		return this.getClass().getFields();
	}

	public int getNumberOfRuns() {
		return numberOfRuns;
	}

	public void setNumberOfRuns(int numberOfRuns) {
		this.numberOfRuns = numberOfRuns;
	}
	
	public float getCoolingRate() {
		return coolingRate;
	}

	public void setCoolingRate(float coolingRate) {
		this.coolingRate = coolingRate / 100;
	}

	public int getMaxTemperatureCycles() {
		return maxTemperatureCycles;
	}

	public void setMaxTemperatureCycles(int maxTemperatureCycles) {
		this.maxTemperatureCycles = maxTemperatureCycles;
	}

	public int getMovesAtEachTemperature() {
		return movesAtEachTemperature;
	}

	public void setMovesAtEachTemperature(int movesAtEachTemperature) {
		this.movesAtEachTemperature = movesAtEachTemperature;
	}

	public int getMaxIdleTemperatureCycles() {
		return maxIdleTemperatureCycles;
	}

	public void setMaxIdleTemperatureCycles(int maxIdleTemperatureCycles) {
		this.maxIdleTemperatureCycles = maxIdleTemperatureCycles;
	}
	
	public Vector<Sensor> getSensors() {
		return sensors;
	}

	public void setSensors(Vector<Sensor> sensors) {
		this.sensors = sensors;
	}

}
